package com.itlong.cloud.sdk.service.impl;


import com.itlong.cloud.POJO.VO.sdk.SDKJDAttriButeVO;
import com.itlong.cloud.sdk.dao.ISDKJdDao;
import com.itlong.cloud.sdk.service.ISDKJdService;
import com.itlong.cloud.utils.words.StringHandlerUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <desc>
 *      京东业务处理接口实现类
 * </desc>
 *
 * @createDate 2020/08/11
 */
@Service
public class SDKJdServiceImpl implements ISDKJdService{
    @Autowired
    ISDKJdDao isdkJdDao;

    /**
     * <desc>
     *      绑定京东设备id
     * </desc>
     *
     * @param deviceId
     * @param deviceUnique
     * @param type 1注册设备 2删除设备1
     * @return
     * @author Jiaqi.X
     * @createDate 2020/08/11
     */
    @Override
    public Integer bindDeviceId(String deviceId, String deviceUnique,Integer type) {
        if(type ==2){
            //删除设备
            deviceId = "";
        }
        return isdkJdDao.bindDeviceId(deviceId,deviceUnique, StringHandlerUtil.getDeviceTypeByDeviceUnique(deviceUnique));
    }

    /**
     * <desc>
     *      检测设备id是否已经被绑定
     * </desc>
     *
     * @param deviceId
     * @param deviceUnique
     * @return
     * @author Jiaqi.X
     * @createDate 2020/08/11
     */
    @Override
    public Integer checkBindDeviceId(String deviceId,String deviceUnique){
        return isdkJdDao.checkBindDeviceId(deviceId,deviceUnique,StringHandlerUtil.getDeviceTypeByDeviceUnique(deviceUnique));
    }

    /**
     * <desc>
     *      初始化京东获取设备属性对象
     * </desc>
     *
     * @param deviceId
     * @param deviceType
     * @return
     * @author Jiaqi.X
     * @createDate 2020/08/11
     */
    @Override
    public SDKJDAttriButeVO initAtrributeVO(String deviceId,Integer deviceType){
        SDKJDAttriButeVO vo = isdkJdDao.getInitAttribute(deviceId,deviceType);
        return vo;
    }

    /**
     * <desc>
     *      京东设备id
     * </desc>
     *
     * @param deviceId
     * @return
     * @author jiaqi.X
     * @createDate 2020/08/17
     */
    @Override
    public String getHwDeviceId(String deviceId,Integer deviceType) {
        return isdkJdDao.getHwDeviceId(deviceId,deviceType);
    }

    /**
     * <desc>
     * 京东设备id
     * </desc>
     *
     * @param deviceUnique 设备编号
     * @param deviceType   设备类型
     * @return
     * @author caoshuai
     * @createDate 2020/09/07
     */
    @Override
    public Map<String, Object> getDeviceInfo(String deviceUnique, Integer deviceType) {
        return isdkJdDao.getDeviceInfo(deviceUnique,deviceType);
    }

    /**
     * <desc>
     * 京东设备id
     * </desc>
     *
     * @param jdDeviceId JD设备编号
     * @param deviceType 设备类型
     * @return
     * @author caoshuai
     * @createDate 2020/09/07
     */
    @Override
    public Map<String, Object> getDeviceInfoByJDDeviceId(String jdDeviceId, Integer deviceType) {
        return isdkJdDao.getDeviceInfoByJDDeviceId(jdDeviceId,deviceType);
    }
}